s = input().replace(' ','')
for a in s:
    if a !='(' and a != ')' and a != '{' and a !=')' and a !='<' and a !='>'and a !='[' and a !=']':
        s=s.replace(a,'')
while '{}' in s or '[]' in s or '()' in s or '<>' in s:
    s = s.replace('{}', '')
    s = s.replace('()', '')
    s = s.replace('[]', '')
    s = s.replace('<>', '')
if len(s) > 0:
    print(False)
else:
    print(True)




